<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>CKEditor Core Tests Runner</title>
	<link rel="stylesheet" type="text/css" href="test.css" />
	<script type="text/javascript">
	//<![CDATA[

var testList =
[
	'core/ajax',
	'core/bootstrap',
	'core/ckeditor',
	'core/editor',
	'core/env',
	'core/event',
	'core/plugins',
	'core/scriptloader',
	'core/tools',
	'core/xml',
	'core/dom/document',
	'core/dom/documentfragment',
	'core/dom/element',
	'core/dom/node',
	'core/dom/range',
	'core/dom/text',
	'core/dom/walker',
	'core/dom/window',
	'core/htmlparser/fragment',
	'core/htmlparser/htmlparser',
	'plugins/domiterator/domiterator',
	'plugins/htmldataprocessor/htmldataprocessor',
	'plugins/link/link',
	'plugins/list/list',
	'plugins/styles/styles',
	'plugins/selection/selection'
];

var currentTest;
var currentTime;
var totalTime;
var totalFailed = 0;
var totalPassed = 0;

function runTest()
{
	currentTest = testList.shift();

	if ( currentTest )
		document.getElementById( 'testFrame' ).src = currentTest + '.html';
}

function onTestStart( data )
{
	var div = document.getElementById('testLogger').appendChild( document.createElement( 'div' ) );
	div.className = 'testEntry';
	div.innerHTML = 'Testing "<a href="' + currentTest + '.html" target="_blank">' + data.testCase.name + '</a>"...';

	currentTime = new Date();

	if ( !totalTime )
		totalTime = currentTime;
}

function onTestComplete( data )
{
	var finishTime = new Date();

	var failed = data.results.failed;
	var passed = data.results.passed;

	var html = '<span class="testIgnore">Unknown</span>';

	if ( failed > 0 )
		html = '<span class="testFail">FAIL</span>';
	else
		html = '<span class="testPass">PASS</span>';

	html += ' Test "<a href="' + currentTest + '.html" target="_blank">' + data.testCase.name + '</a>" (' + failed + ' failed / ' + passed + ' passed) - ' + ( finishTime - currentTime ) + 'ms';

	var div = document.getElementById('testLogger').lastChild;
	div.innerHTML = html;

	totalFailed += failed;
	totalPassed += passed;

	document.getElementById('testFailed').innerHTML = totalFailed;
	document.getElementById('testPassed').innerHTML = totalPassed;
	document.getElementById('totalTime').innerHTML = finishTime - totalTime;

	document.title = totalFailed + ' failed / ' + totalPassed + ' passed - CKEditor Core Tests Runner';

	runTest();
}

window.onload = function()
{
	// IE was "caching" the latest logged div on refresh. So, we must clean it
	// on startup.
	document.getElementById('testLogger').innerHTML = '';

	runTest();
};

	//]]>
	</script>
</head>
<body>
	<h1>CKEditor Core Tests Runner (<span id="testFailed">0</span> failed / <span id="testPassed">0</span> passed) - <span id="totalTime">0</span>ms</h1>
	<iframe id="testFrame" src="javascript:;" style="position: absolute; width: 50px; height: 50px; left: -1000px">
	</iframe>
	<div id="testLogger" class="testAll"></div>
</body>
</html>
